﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Profile.aspx.cs" Inherits="Web.Profile" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">

    <link rel="stylesheet" href="Share/Styles/Profile.css" />

    <% if (PermissionService.CanChangeProfile(SelectedUser))
       { %>
    <script type="text/javascript">
        function ShowUploadPhotoMessage(message) {
            top.$get("<%= LblFileUploadProfilePhotoMessage.ClientID %>").innerHTML = message;
        }

        function ClearUploadPhotoMessage() {
            top.$get("<%= LblFileUploadProfilePhotoMessage.ClientID %>").innerHTML = "";
        }

        function ChangeProfilePhoto(path) {
            top.$get("ImgProfilePhoto").setAttribute('src', path);
        }

        function SaveCancelProfilePhotoBtnVisible(display) {
            top.$get("<%= BtnSaveProfilePhoto.ClientID %>").style.display = display;
            top.$get("<%= BtnCancelProfilePhoto.ClientID %>").style.display = display;
        }
    </script>
    <% } %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Main" runat="server">

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <section id="Profile" class="clear-fix">

                <header class="border-bottom-silver clear-fix">
                    <h2 runat="server" id="ProfileHeader"></h2>
                    <% if (PermissionService.CanChangeProfile(SelectedUser))
                       { %>
                    <asp:LinkButton runat="server" ID="BtnEditProfile" CssClass="right-top button" Text="Изменить" OnClick="BtnEditProfile_OnClick" />
                    <% } %>
                </header>

                <div class="left">

                    <div id="ProfilePhoto">
                        <asp:Image runat="server" ID="ImgProfilePhoto" CssClass="img-shadow" />
                    </div>

                    <div id="Buttons">
                        <% if (PermissionService.CanChangeProfile(SelectedUser))
                           { %>
                        <div id="ProfilePhotoUploadWrapper">
                            <label runat="server" id="LblFileUploadProfilePhotoMessage" />
                            <label>
                                <a id="BtnChangeProfilePhoto" title="Выбрать новую фотографию" class="button">Выбрать новую фотографию</a>

                                <ajaxToolkit:AsyncFileUpload runat="server" ID="FileUploadProfilePhoto" ThrobberID="Trobbler"
                                    CompleteBackColor="" ErrorBackColor="red" ForeColor=""
                                    OnUploadedComplete="FileUploadProfilePhoto_OnUploadedComplete" />
                                <img runat="server" id="Trobbler" src="/Share/Images/uploading.gif" alt="Идет загрузка" />
                            </label>

                            <asp:Button runat="server" ID="BtnDeleteProfilePhoto" CssClass="button" Text="Удалить фотографию" OnClick="BtnDeleteProfilePhoto_OnClick" />
                            <asp:Button runat="server" ID="BtnSaveProfilePhoto" CssClass="hidden button" Text="Сохранить" OnClick="BtnSaveProfilePhoto_OnClick" />
                            <asp:Button runat="server" ID="BtnCancelProfilePhoto" CssClass="hidden button" Text="Отменить" OnClick="BtnCancelProfilePhoto_OnClick" />
                        </div>
                        <% } %>
                    </div>

                </div>

                <div class="right">

                    <% if (PermissionService.CanChangeProfile(SelectedUser))
                       { %>
                    <div runat="server" visible="False" id="EditProfileCardForm" class="inset-shadow box w570 form">

                        <div runat="server" id="EditProfileCardFormError" class="form-error" />

                        <table>
                            <tr>
                                <td>ФИО</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbProfileFio" />
                                </td>
                            </tr>
                            <tr>
                                <td>Телефон</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbProfilePhone" />
                                </td>
                            </tr>
                            <tr>
                                <td>Дата рождения</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbProfileBirthDate" CssClass="datepicker" />
                                </td>
                            </tr>
                            <tr>
                                <td>ICQ</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbProfileIcq" />
                                </td>
                            </tr>
                            <tr>
                                <td>Skype</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbProfileSkype" />
                                </td>
                            </tr>
                            <tr>
                                <td>Страничка в интернете</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbProfilePersonalPage" />
                                </td>
                            </tr>
                            <tr>
                                <td>О себе</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbProfileAboutMyself" TextMode="MultiLine" Rows="5" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <asp:Button runat="server" ID="BtnSaveProfileCatd" Text="Сохранить" CssClass="button" OnClick="BtnSaveProfileCard_OnClick" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <asp:Button runat="server" ID="BtnCancelProfileCard" Text="Отменить" CssClass="button" OnClick="BtnCancelProfileCard_OnClick" />
                                </td>
                            </tr>
                        </table>

                        <table runat="server" id="BtnChangePasswordWrap">
                            <tr>
                                <td></td>
                                <td>
                                    <asp:LinkButton runat="server" ID="BtnChangePassword" Text="Именить пароль" CssClass="button" OnClick="BtnChangePassword_OnClick" /></td>
                            </tr>
                        </table>

                        <table runat="server" id="ChangePasswordForm" visible="False">
                            <tr>
                                <td>Старый пароль</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbOldPassword" TextMode="Password" />
                                </td>
                            </tr>
                            <tr>
                                <td>Новый пароль</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbNewPassword" TextMode="Password" />
                                </td>
                            </tr>
                            <tr>
                                <td>Подтвердите пароль</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbNewPasswordConfirm" TextMode="Password" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <asp:Button runat="server" ID="BtnSavePassword" Text="Соранить" CssClass="button" OnClick="BtnSavePassword_OnClick" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <asp:Button runat="server" ID="BtnCancelPassword" Text="Отменить" CssClass="button" OnClick="BtnCancelPassword_OnClick" />
                                </td>
                            </tr>
                        </table>

                        <table runat="server" id="BtnChangeEmailWrap">
                            <tr>
                                <td></td>
                                <td>
                                    <asp:LinkButton runat="server" ID="BtnChangeEmail" Text="Именить e-mail" CssClass="button" OnClick="BtnChangeEmail_OnClick" /></td>
                            </tr>
                        </table>

                        <table runat="server" id="ChangeEmailForm" visible="False">
                            <tr>
                                <td>Новый e-mail</td>
                                <td>
                                    <asp:TextBox runat="server" ID="TbEmail" TextMode="Email" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <asp:Button runat="server" ID="BtnSaveEmail" Text="Соранить" CssClass="button" OnClick="BtnSaveEmail_OnClick" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <asp:Button runat="server" ID="BtnCancelEmail" Text="Отменить" CssClass="button" OnClick="BtnCancelEmail_OnClick" />
                                </td>
                            </tr>
                        </table>

                    </div>
                    <% } %>

                    <section id="ProfileCard" class="inset-shadow box w570">
                        <table>
                            <% if (!string.IsNullOrEmpty(SelectedUser.UserProfile.Phone))
                               { %>
                            <tr>
                                <td>Телефон</td>
                                <td>
                                    <asp:Label runat="server" ID="LblPhone" /></td>
                            </tr>
                            <% } %>
                            <% if (SelectedUser.UserProfile.BirthDate != null)
                               { %>
                            <tr>
                                <td>Дата рождения</td>
                                <td>
                                    <asp:Label runat="server" ID="LblBirthDate" /></td>
                            </tr>
                            <% } %>
                            <% if (!string.IsNullOrEmpty(SelectedUser.UserProfile.Icq))
                               { %>
                            <tr>
                                <td>ICQ</td>
                                <td>
                                    <asp:Label runat="server" ID="LblIcq" /></td>
                            </tr>
                            <% } %>
                            <% if (!string.IsNullOrEmpty(SelectedUser.UserProfile.Skype))
                               { %>
                            <tr>
                                <td>Skype</td>
                                <td>
                                    <asp:Label runat="server" ID="LblSkype" /></td>
                            </tr>
                            <% } %>
                            <% if (!string.IsNullOrEmpty(SelectedUser.UserProfile.PersonalPage))
                               { %>
                            <tr>
                                <td>Страничка в интернете
                                </td>
                                <td>
                                    <asp:HyperLink runat="server" ID="LinkPersonalPage" />
                                </td>
                            </tr>
                            <% } %>
                            <% if (!string.IsNullOrEmpty(SelectedUser.UserProfile.AboutMyself))
                               { %>
                            <tr>
                                <td>О себе
                                </td>
                                <td>
                                    <asp:Label runat="server" ID="LblAboutMyself" /></td>
                            </tr>
                            <% } %>
                        </table>
                    </section>

                </div>

            </section>
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
